package com.madding.shared.encrypt.cert.bc.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.bouncycastle.jce.X509Principal;

/**
 * 证书数据模型
 * 
 * @author madding.lip
 */
public class CertModel implements Serializable {

    private static final long serialVersionUID = 1L;

    private X509Principal     issueName;
    private X509Principal     subjectName;
    private Date              notBefore;
    private Date              notAfter;
    private List<String>      extensions;

    public X509Principal getIssueName() {
        return issueName;
    }

    public void setIssueName(X509Principal issueName) {
        this.issueName = issueName;
    }

    public X509Principal getSubjectName() {
        return subjectName;
    }

    public void setSubjectName(X509Principal subjectName) {
        this.subjectName = subjectName;
    }

    public Date getNotBefore() {
        return notBefore;
    }

    public void setNotBefore(Date notBefore) {
        this.notBefore = notBefore;
    }

    public Date getNotAfter() {
        return notAfter;
    }

    public void setNotAfter(Date notAfter) {
        this.notAfter = notAfter;
    }

    public List<String> getExtensions() {
        return extensions;
    }

    public void setExtensions(List<String> extensions) {
        this.extensions = extensions;
    }

    public boolean valid() {
        // condition 1:主题校验

        // condition 2:颁发者校验

        // condition 3:日期校验
        if (notBefore.getTime() > notAfter.getTime()) {
            return false;
        }

        return true;
    }

}
